package com.hp.team.bookstore.model.order;

import java.util.Calendar;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import com.hp.team.bookstore.model.profile.User;

@Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public abstract class Order implements Comparable<Order>{

	/*
	 * Use "GenerationType.TABLE" for table-per-class inheritance strategy.
	 */
	@Id
	@GeneratedValue(strategy = GenerationType.TABLE)
	@Column(name = "ID")
	private long id;

	@OneToOne
	@JoinColumn(name = "CREATOR_ID")
	private User creator;

	@Column(name = "TAXES")
	private double taxes;

	@Column(name = "SHIPPING_FEES")
	private double shippingFees;

	@Column(name = "SUB_TOTAL_PRICE")
	private double subTotalPrice;

	@Column(name = "GRAND_TOTAL_PRICE")
	private double grandTotalPrice;

	@Temporal(TemporalType.DATE)
	@Column(name = "DATE")
	private Calendar date;

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public User getCreator() {
		return creator;
	}

	public void setCreator(User creator) {
		this.creator = creator;
	}

	public double getTaxes() {
		return taxes;
	}

	public void setTaxes(double taxes) {
		this.taxes = taxes;
	}

	public double getShippingFees() {
		return shippingFees;
	}

	public void setShippingFees(double shippingFees) {
		this.shippingFees = shippingFees;
	}

	public double getSubTotalPrice() {
		return subTotalPrice;
	}

	public void setSubTotalPrice(double subTotalPrice) {
		this.subTotalPrice = subTotalPrice;
	}

	public double getGrandTotalPrice() {
		return grandTotalPrice;
	}

	public void setGrandTotalPrice(double grandTotalPrice) {
		this.grandTotalPrice = grandTotalPrice;
	}

	public Calendar getDate() {
		return date;
	}

	public void setDate(Calendar date) {
		this.date = date;
	}

	@Override
	public int compareTo(Order otherOrder) {
		return (int) (id - otherOrder.id);
	}
}
